$(function(){
	var imageuploader = document.getElementById('imageuploader');
	var previewer = document.getElementById('previewer');
	imageuploader.onchange = function(){
		var selectedFile = this.files[0];
		var reader = new FileReader();
		reader.onload = function(){
			previewer.src = reader.result;
		}
		reader.readAsDataURL(selectedFile);
	}
	
	//移出去
	$('#username').on('blur',function(event){
		var $self = $(this)  //就是input里的id
		$.post('./check.do',{username: $self.val()},function(data){
			//console.log(data);
			if(data.ok === 1){
				$self.closest('.form-group').addClass('has-success has-feedback');
				$self.after('<span class="glyphicon glyphicon-ok form-control-feedback" aria-hidden="true"></span>');
			}else{
				$self.closest('.form-group').addClass('has-error has-feedback');
				$self.after('<span class="glyphicon glyphicon-remove form-control-feedback" aria-hidden="true"></span>');
			}
		})
	})
	
	//移进去会消失
	$('#username').on('focus',function(){
		var $self = $(this)
		$.post('./check.do',{username: $self.val()},function(data){
			$self.closest('.form-group').removeClass('has-success has-error has-feedback');
			$self.next().remove();
		})
	})
})